<?php


class sfWidgetFormInputRang  extends sfWidgetForm
{

    protected function configure($options = array(), $attributes = array())
    {
        //$this->addRequiredOption('partial_name');
$this->addOption('template',<<<EOF
<div class="inputCollection"> 
  <div class="smallTitle">From </div> <div class="smallInput">%from%</div>
</div>

<div class="inputCollection"> 
  <div class="smallTitle">To </div> <div class="smallInput">%to%</div>
</div>
EOF

);
        //parent::configure($options, $attributes);
    }

    /**
   * @param  string $name        The element name
   * @param  string $value       The date displayed in this widget
   * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
   * @param  array  $errors      An array of errors for the field
   *
   * @return string An HTML tag string
   *
   * @see sfWidgetForm
   */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        
        $id = $this->generateId($name);
        $value_from = "";
        $value_to = "";

        if(is_array($value) && count($value) > 0){
            $value_from = $value['from'];
            $value_to = $value['to'];

        }
        $attr1 = array();
        $attr1['id'] = $id.'_from';
        $attr1['name'] = $name.'[from]';
        $attr1['value'] = $value_from;
        
        $html_from  = $this->renderTag( 'input' , array_merge($attributes , $attr1) );
        //$html_from .= $this->renderTag( 'input' , array_merge($attributes , $attr1) );

        $attr2 = array();
        $attr2['id'] = $id.'_to';
        $attr2['name'] = $name.'[to]';
        $attr2['value'] = $value_to;
        
        //$html_to .= $this->renderTag( 'input' , array_merge($attributes , $attr2) );
        $html_to  = $this->renderTag( 'input' , array_merge($attributes , $attr2) );

        return strtr($this->getOption('template'),array('%from%'=>$html_from,'%to%'=>$html_to));
        //return $html_from.''.$html_to;
    }


    public function getStylesheets()
    {
        return array();
    }

    /**
   * Gets the JavaScript paths associated with the widget.
   *
   * @return array An array of JavaScript paths
   */
    public function getJavaScripts()
    {
        return array();
    }
}
